//
//  WKHttpHeader.m
//  ourToken
//
//  Created by wakeup on 2018/6/25.
//  Copyright © 2018年 ourtoken. All rights reserved.
//

#import "WKHttpHeader.h"

@implementation WKHttpHeader

+ (WKHttpHeader *)sharedManager {
    static WKHttpHeader *instance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[WKHttpHeader alloc] init];
    });
    
    return instance;
}

- (instancetype)init {
    self = [super init];
    
    if (self) {
        
        self.manager = [AFHTTPSessionManager manager];
        
        self.manager.requestSerializer = [AFJSONRequestSerializer serializer];
        //设置请求超时
        self.manager.requestSerializer.timeoutInterval = 30;
        //设置请求参数格式
        [self.manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
        //设置返回格式
        self.manager.responseSerializer = [AFHTTPResponseSerializer serializer];
        
        //        self.manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/html",@"image/jpeg",@"text/plain", nil];
        
        self.manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/xml",@"text/xml",@"text/javascript",@"text/plain",@"application/json",@"text/json",@"text/html", nil];
        
    }
    return self;
}

@end
